# Maintainer: Lubosz Sarnecki <lubosz@gmail.com>

_realname=gst-python
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-gst-python")
pkgver=1.16.2
pkgrel=2
pkgdesc="GStreamer GObject Introspection overrides for Python (mingw-w64)"
arch=('any')
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gstreamer"
         "${MINGW_PACKAGE_PREFIX}-python-gobject")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-pygobject-devel"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja")
url='https://gstreamer.freedesktop.org/modules/gst-python.html'
source=(https://gstreamer.freedesktop.org/src/gst-python/${_realname}-${pkgver}.tar.xz)
sha256sums=('208df3148d73d9f416d016564737585d8ea763d91201732d44b5fe688c6288a8')

prepare() {
  cd ${_realname}-${pkgver}

}

build() {
  rm -rf python-build
  mkdir python-build
  cd python-build

  ${MINGW_PREFIX}/bin/meson \
    --buildtype plain \
    --wrap-mode=nofallback \
    -Dauto_features=enabled \
    -Dpython=${MINGW_PREFIX}/bin/python \
    ../${_realname}-${pkgver}

  ninja
}

package() {
  cd python-build

  DESTDIR="${pkgdir}${MINGW_PREFIX}" ninja install

  # The python plugin loader makes problems because it links against libpython
  # which might be in conflict one already used loading the plugin.
  # The overrides don't need it so just remove it for now.
  # https://github.com/Alexpux/MINGW-packages/issues/2034
  rm -r "${pkgdir}${MINGW_PREFIX}/lib/gstreamer-1.0"
}
